import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_project/common/route_page/route_name.dart';
import 'package:flutter_project/config/theme_color.dart';
import 'package:get/get.dart';
import 'common/route_page/route_page.dart';
import 'config/common_string_config.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MediaQuery(
        data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
        child: GetMaterialApp(
          navigatorKey: RouteNames.navigatorKey,
          title: CommonStringConfig.appTitle,
          debugShowCheckedModeBanner: false,
          locale: const Locale('zh', 'CH'),
          //默认是中文
          localizationsDelegates: const [
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          supportedLocales: const [
            Locale('zh', 'CH'), //支持列表，中文
            Locale('en', 'US'), //支持列表，英文
          ],
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: ThemeColor.mainColor),
            appBarTheme: AppBarTheme.of(context).copyWith(
              backgroundColor: ThemeColor.mainColor,
            ),
            useMaterial3: true,
            unselectedWidgetColor: Colors.red
          ),
          initialRoute: RouteNames.initialPage,
          onGenerateRoute: generateRoutes,
          builder: EasyLoading.init(),
        ));
  }
}
